<?php

error_reporting(E_ERROR);
session_start();
if(!isset($_SESSION["SESSION_codUsuario"])){
    echo json_encode(array("ERROR"=>"La sesión ha caducado, verifique."));                
    exit();
}

require_once('../modelo/GestionBoleta.php');

if($_GET["operation"] === "checkClient"){
    echo GestionBoleta::CheckClient($_GET["nameOrId"]);
}
else if($_GET["operation"] === "getDrawValue"){
    echo GestionBoleta::GetDrawValue($_GET["idSorteo"]);
}
else if($_GET["operation"] === "GetAccumulated"){
    echo GestionBoleta::GetAccumulated($_GET["idCliente"]);
}


else if($_POST["operation"] === "generateTicket"){
    
    $idClient = $_POST["idClient"];
    $sorteo = $_POST["codSorteo"];
    $empresa = $_POST["empresa"];
    $numFactura = $_POST["numFactura"];
    $valFactura = $_POST["valFactura"];
    
    $codUsuario = $_SESSION["SESSION_codUsuario"];
    
    echo GestionBoleta::GenerateTicket($codUsuario, $idClient, $sorteo, $empresa, $numFactura, $valFactura);
}
//else if($_POST["operation"] === "printTickets"){
//    
//    $clientName = $_POST["client_name"];
//    $phone = $_POST["phone"];
//    $email = $_POST["email"];
//    $tickets = $_POST["tickets"];        
//    $id= $_POST["id"];   
//    
//    echo GestionBoleta::PrintTickets($id, $clientName, $phone, $email, $tickets);
//}